import React, { useState, useRef, useEffect } from 'react';
const UseRef = () => {
  const inputEl = useRef(null);

  const changeInputValue = () => {
    inputEl.current.value = 'hellow fff';
    console.log(inputEl);
  }

  const [text, setText] = useState('Hellow fff');
  const textRef = useRef();
  useEffect(()=> {
    textRef.current = text;
    console.log(textRef.current);
  })

  return (
    <>
      <input ref={inputEl} type="text"/>
      <button onClick={changeInputValue}>传送fff</button>
      <br />
      <br />
      <input value={text} onChange={(e)=>{setText(e.target.value)}} type="text"/>
    </>
  )
}
export default UseRef;